package com.mazaiting.auth.security.core.userdetails.member;

import com.mazaiting.auth.security.core.userdetails.base.BaseUserDetails;
import lombok.Getter;
import lombok.Setter;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;
import java.util.HashSet;


/**
 * 用户认证信息
 */
@Setter
@Getter
public class MemberUserDetails extends BaseUserDetails {
    /**
     * 会员 ID
     */
    private Long memberId;
    /**
     * 是否可用
     */
    private Boolean enabled;

    /**
     * 会员用户体系
     */
    public MemberUserDetails() {
        this.setMemberId(1L);
        this.setUsername("root");
        this.setEnabled(true);
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return new HashSet<>();
    }

    @Override
    public String getPassword() {
        return null;
    }

    @Override
    public String getUsername() {
        return this.username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return this.enabled;
    }
}
